﻿/**
 * 獲取应用程序域获公共定義, 類、命名空间等
 * 
 */
package com.kucooler.common.utils {
	import flash.accessibility.AccessibilityImplementation;
	import flash.display.SWFVersion;
	import flash.events.Event;
    import flash.system.*;
	/**
	 * ...
	 * @author lmzd
	 */
	public class MaterialLib extends Object {
		
		private var _materialArray:Array;
		private var _materialUrlArr:Array;
		
		private static var _instance:MaterialLib;		

		public function MaterialLib() {
			_materialArray = [];
			_materialUrlArr = [];
			if ( _instance != null ) {
				trace("MaterialLib's Class Instance Error!");
				return;
			}
			return;
		}		
		public function push(param1:ApplicationDomain, param2:String = "") : void {
            if (param2 != "")
            {
                _materialUrlArr.push(param2);
            }
            _materialArray.push(param1);
            return;
        }
		public function getClass(paraml:String):Object {
			var _loc_2:int;
            var _loc_3:* = _materialArray.length;
            while (_loc_2 < _loc_3){                
                if ((_materialArray[_loc_2] as ApplicationDomain).hasDefinition(paraml)){
                    return (_materialArray[_loc_2] as ApplicationDomain).getDefinition(paraml) as Class;
                }
                _loc_2++;
            }
            return null;
		}
		public function getMaterialLib(paraml:String):Object {
			var _temp:Object = getClass(paraml);
			if (_temp != null) {
				return new _temp;				
			}
			return null;			
		}
		public static function getInstance():MaterialLib {			
			if ( _instance == null) {				
				_instance = new MaterialLib();
			}
			return _instance;
		}
		
		
	}
}
